Cleanup domain listing.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Thu, 1 Sep 2005 10:08:53 +0000 (10:08 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Thu, 1 Sep 2005 10:08:53 +0000 (10:08 +0000)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/server/SrvDomainDir.py
tools/python/xen/xend/server/event.py

index 3959b2e9173ccecb116beed56baef9e3408256ab..080fc4ae8b700525b35d58ee34909cc4b2d6bee3 100644 (file)
@@ -75,8 +75,26 @@ class XendDomain:
 
         @return: domain objects
         """
+        self.refresh()
         return self.domains.values()
-    
+
+    def list_sorted(self):
+        """Get list of domain objects, sorted by name.
+
+        @return: domain objects
+        """
+        doms = self.list()
+        doms.sort(lambda x, y: cmp(x.name, y.name))
+        return doms
+
+    def list_names(self):
+        """Get list of domain names.
+
+        @return: domain names
+        """
+        doms = self.list_sorted()
+        return map(lambda x: x.name, doms)
+
     def onVirq(self, event, val):
         """Event handler for virq.
         """
@@ -265,24 +283,6 @@ class XendDomain:
         else:
             self._delete_domain(id)
 
-    def domain_ls(self):
-        """Get list of domain names.
-
-        @return: domain names
-        """
-        self.refresh()
-        doms = self.domains.values()
-        doms.sort(lambda x, y: cmp(x.name, y.name))
-        return map(lambda x: x.name, doms)
-
-    def domain_ls_ids(self):
-        """Get list of domain ids.
-
-        @return: domain names
-        """
-        self.refresh()
-        return self.domains.keys()
-
     def domain_create(self, config):
         """Create a domain from a configuration.
 
index 613841ddff680102f1058c7bf092e8ea3a8f7dc7..2b5f873fd38910691d9dbac8655ffd914e6dded2 100644 (file)
@@ -146,11 +146,10 @@ class SrvDomainDir(SrvDir):
         if not url.endswith('/'):
             url += '/'
         if use_sxp:
-            domains = self.xd.domain_ls()
+            domains = self.xd.list_names()
             sxp.show(domains, out=req)
         else:
-            domains = self.xd.list()
-            domains.sort(lambda x, y: cmp(x.name, y.name))
+            domains = self.xd.list_sorted()
             req.write('<ul>')
             for d in domains:
                req.write('<li><a href="%s%s"> Domain %s</a>'
index 360cd47a9b222322d50c7fcb6548001305e918a5..eee9b0594cca31f6ffabcda7bbd355482c2c6036 100644 (file)
@@ -186,7 +186,7 @@ class EventProtocol(protocol.Protocol):
 
     def op_domain_ls(self, name, v):
         xd = xroot.get_component("xen.xend.XendDomain")
-        return xd.domain_ls()
+        return xd.list_names()
 
     def op_domain_configure(self, name, v):
         domid = sxp.child_value(v, "dom")